When is a Web Service constructor called? [Java Netbeans 6.7.1 & Tomcat 6.0.18]

Posted by Shaitan00 on Stack Overflow See other posts from Stack Overflow or by Shaitan00
Published on 2009-11-16T06:26:08Z Indexed on 2010/05/14 20:04 UTC
Read the original article Hit count: 186

Filed under:
|

I am migrating a Java RMI application to Java Web Service (school assignment) and I've encountered an issue...

Currently my Java Server creates an instance of the Remote Object, this object has a constructor and takes a parameter (int ID) which tells it which database to load in memory - works like a charm ...

Now, migrating this to Web Services is causing my a problem - first I needed to add a default constructor because it wouldn't deploy without it, and then while doing some reading all these discussions about "stateless web services" kept coming up ...

For example, if I "start" my webservice with parameter(0) it would load from Databse 0 and all requests from Clients would be done using that data... I want this to only happen when I start the WebService and NOT everytime the client connects... Loading from the DB is expensive and takes time, so I want to do it once so that clients when they connect just deal with the data in memory ...

This is how it works with my Java RMI .... but can this also work with Web Services?

Any advice would be much appreciated. Thanks,

© Stack Overflow or respective owner

Related posts about java

Related posts about webservice